// logs.js
// const util = require('../../utils/util.js')

Page({
  data: {
    region:'浙江省温州市苍南县',
    address:''
  },
  onLoad() {
  },
  onShow(){
    let addreess1=wx.getStorageSync("ADDRESS1");
    let addreess2=wx.getStorageSync("ADDRESS2");
    if(addreess1){
      this.setData({region:addreess1,address:addreess2})
    }
  },
  /**
   * 修改地区
   */
  bindRegionChange: function (e) {
    var that = this;
    var region = e.detail.value.join('')
    this.setData({
      region: e.detail.value
    })
    // var url = `https://apis.map.qq.com/ws/geocoder/v1/?address=${region}&key=${App.mapKey}`
    // wx.request({
    //   url: url,
    //   success(res) {
    //     const longitude = res.data.result.location.lng;
    //     const latitude = res.data.result.location.lat;
    //     that.setData({
    //       longitude: longitude,
    //       latitude: latitude,
    //       address: ''
    //     })
    //     wx.setStorageSync('address', '')
    //     wx.setStorageSync('longitude', '');
    //     wx.setStorageSync('latitude', '');
    //   }
    // })
  },
  charChange(e){
    let value=e.detail.value;
    this.setData({address:value});
  },
  save(e){
    wx.setStorageSync("ADDRESS1",this.data.region);
    wx.setStorageSync("ADDRESS2",this.data.address);
    wx.redirectTo({
      url:"/pages/home/home"
    });
  }
})
